$(function () {
    //抽取js变量
    var dept_datagrid = $("#dept_datagrid");
    var salary_dialog = $("#salary_dialog");
    var mission_form = $("#salary_form");
    $("#box").on('click', 'a.my_btn', function () {
        var index = $(this).data("index");
        var rows = dept_datagrid.datagrid("getRows");
        var row = rows[index];
        salary_dialog.dialog("open");
        mission_form.form("load", row);


    });

    dept_datagrid.datagrid({
        url: '/salary/query.do',
        fitColumns: true,
        fit: true,//自动填充
        toolbar: '#dept_toolbar',
        pagination: true, //在DataGrid控件底部显示分页工具栏
        rownumbers: true, //显示一个行号列。
        singleSelect: true,//只允许选择一行
        striped: true, //显示斑马线效果
        columns: [[
            {field: 'id', checkbox: true},
            {field: 'employeeusername', title: '姓名', width: 80},
            {field: 'deptname', title: '部门', width: 80},
            {field: 'tel', title: '电话', width: 80},
            {field: 'email', title: '邮箱', width: 80},
            {field: 'basicsalary', title: '基本工资', width: 80},
            {field: 'bonus', title: '奖金', width: 80},
            {field: 'hiredate', title: '日期', width: 80},
            {field: 'annualsalary', title: '总薪资', width: 80},
            {
                field: 'button', title: '查看薪资明细', width: 80, formatter: function (value, row, index) {
                    return "<a href='javascript:' data-index='" + index + "' class='easyui-linkbutton my_btn'>查看</a>";
                }
            }

        ]]
    });

    $("#dept_toolbar a").click(function () {
        var keyword1 = $("#keyword").textbox('getValue');
        var deptName1 = $("#deptName").combobox('getValue');
        var beginDate1 = $("#beginDate").datebox('getValue');
        var endDate1 = $("#endDate").datebox('getValue');

        dept_datagrid.datagrid('load', {
            keyword: keyword1,
            deptName: deptName1,
            beginDate: beginDate1,
            endDate: endDate1
        });
    })

    salary_dialog.dialog({
        title: "传说中的薪资明细单",
        width: 250,
        height: 280,
        top: 100,
        closed: true,
        onClose: function () {
            mission_form.form('clear');
        }
    });


});










